from flask import Flask, request, redirect, render_template, session,url_for
# url_for 反向生成
app = Flask(__name__)
app.secret_key = 'niedoqebowoefweihiowefihwf'


@app.route('/', methods=['GET'])
def asd():
    return redirect('/login')

# 通过正则这种方式获取query参数
"""
@app.route('/user/<username>')  # 直接写就是字符串
@app.route('/post/<int:post_id>')   # int
@app.route('/post/<float:post_id>') # float
@app.route('/post/<path:path>')     # path
@app.route('/login', methods=['GET', 'POST'])
"""
"""
内部的转换器 = DEFAULT_CONVERTERS = {
    'default':          UnicodeConverter,
    'string':           UnicodeConverter,
    'any':              AnyConverter,
    'path':             PathConverter,
    'int':              IntegerConverter,
    'float':            FloatConverter,
    'uuid':             UUIDConverter,
}
"""

@app.route('/login/<int:uid>', methods=['GET', 'POST'],endpoint='n1')
def login(uid):
    print(uid)
    return "login"


@app.route('/index', methods=['GET'],endpoint='n2')
def index():
    return "index"

@app.route('/logout', methods=['GET'],endpoint='n3')
def logout():
    return "logout"


if __name__ == '__main__':
    app.run(debug=True)